//
// Created by xili on 2024/9/3 20:59.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    bool asteroidsDestroyed(int mass, vector<int> &asteroids) {
        ranges::sort(asteroids);
        int n = asteroids.size();
        long long sum = 0;
        for (int i = 0; i < n; i++) {
            if (sum + mass < asteroids[i]) {
                return false;
            }
            sum += asteroids[i];
        }
        return true;
    }
};